<div class="row">
    <div class="col-md-12">
        <!-- BEGIN VALIDATION STATES-->
        <div class="portlet light portlet-fit portlet-form bordered">
            <div class="portlet-title">
                <div class="caption">
                    <i class=" icon-layers font-green"></i>
                    <span class="caption-subject font-green sbold">用户表单</span>
                </div>
            </div>
            <div class="portlet-body">
                <!-- BEGIN FORM-->
                <form action="?r=user/userinfo/<?= $action ?>" class="form-horizontal" id="validation-form" method="post">
                    <div class="form-body">
                        <?php echo $this->render('@app/backend/views/common/form_tip');?>
                        <div class="form-group">
                            <label class="control-label col-md-3">手机号
                                <span class="required"> * </span>
                            </label>
                            <div class="col-md-2">
                                <input type="text" name="User[phone]" class="form-control username"
                                       value="<?php echo isset($user['phone'])?$user['phone']:'';?>"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">登录密码
                                <span class="required"> * </span>
                            </label>
                            <div class="col-md-2">
                                <input type="password" name="User[password]" class="form-control password"
                                       value=""/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">姓名
                                <span class="required"> * </span>
                            </label>
                            <div class="col-md-2">
                                <input type="text" name="User[name]" class="form-control nickname"
                                    value="<?php echo isset($user['name'])?$user['name']:'';?>"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">邮箱
                                <span class="required"> * </span>
                            </label>
                            <div class="col-md-2">
                                <input type="text" name="User[email]" class="form-control"
                                       value="<?php echo isset($user['email'])?$user['email']:'';?>"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">生日
                                <span class="required"> * </span>
                            </label>
                            <div class="col-md-2">
                                <input type="text" name="User[birthday]" class="form-control"
                                       value="<?php echo isset($user['birthday'])?date('Y-m-d',$user['birthday']):'';?>"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">性别
                                <span class="required"> * </span>
                            </label>                        
                            <div class="col-md-4">
                                <input type="radio" id="qqq" name="User[sex]" value="1" <?php echo isset($user['sex'])&&$user['sex'] == 1?'checked':'checked' ?>><label for="qqq">男</label>
                                <input type="radio" id="qq" name="User[sex]" value="0" <?php echo isset($user['sex'])&&$user['sex'] == 0?'checked':'' ?>><label  for="qq">女</label>
                        	</div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">身份证号
                                <span class="required"> * </span>
                            </label>
                            <div class="col-md-2">
                                <input type="text" name="User[identity_num]" class="form-control"
                                       value="<?php echo isset($user['identity_num'])?$user['identity_num']:'';?>"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">角色
                                <span class="required"> * </span>
                            </label>
                            <div class="col-md-2">
                                <select class="bs-select form-control" name="User[role]">
                                    <option value="">--请选择--</option>
                                    <?php foreach ($role as $v) :?>
                                    <option <?php if(isset($user['role']) && $user['role']==$v['id']):?>selected<?php endif;?> value="<?php echo $v['id'];?>"><?php echo $v['name'];?></option>
                                    <?php endforeach;?>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <div class="row">
                            <div class="col-md-offset-3 col-md-9">
                                <button type="submit" class="btn green submit">提交</button>
                                <button type="reset" class="btn default">取消</button>
                            </div>
                        </div>
                    </div>
                    <input type="hidden" name="_csrf" value="<?php echo Yii::$app->request->getCsrfToken()?>" />
                </form>
                <!-- END FORM-->
            </div>
        </div>
        <!-- END VALIDATION STATES-->
    </div>
</div>
<script>
    $.ajax({
        url: CONFIG.url+'/api/createDemoUser',
        type: 'POST',
        data: params,
        contentType: 'application/x-www-form-urlencoded',
        beforeSend: function (req) {
            req.setRequestHeader('appkey', CONFIG.appkey);
        },
        success: function(data) {
            if (data.res === 200) {
                alert("注册成功");
                window.location.href = './index.html';
            }else{
                that.$errorMsg.html(data.errmsg).removeClass('hide');
                that.$submit.html('注册').removeAttr('disabled');
            }
        },
        error: function() {
            that.$errorMsg.html('请求失败，请重试');
        }
    });
</script>